﻿using System.Data;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NazTek.Extension.Clr4.Test
{    
    /// <summary>
    ///This is a test class for EnumerableExtensionTest and is intended
    ///to contain all EnumerableExtensionTest Unit Tests
    ///</summary>
    [TestClass()]
    public class EnumerableExtensionTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void TestToString()
        {
            IEnumerable<string> oStringArray = new string[] { "one", "two", "three" };
            Assert.AreEqual<string>("one,two,three", oStringArray.ToString<string>(","));
            IEnumerable<int> oIntArray = new int[] { 1, 2, 3 };
            Assert.AreEqual<string>("1,2,3", oIntArray.ToString<int>(","));
        }
        [TestMethod()]
        public void TestToString_Compact()
        {
            IEnumerable<string> oStringArray = new string[] { "one", null, "two", "", "three", " " };
            Assert.AreEqual<string>("one,two,three", oStringArray.ToString<string>(",", true));
        }
        [TestMethod()]
        public void TestGetDataSet()
        {
            DataSet actual = MockData.MockPersonEnumerator.GetDataSet<MockPerson>();
            Assert.AreEqual<string>(MockData.MockPersonListXml, actual.GetUnformattedXml());
        }
        [TestMethod()]
        public void TestGetDataTable()
        {
            DataTable actual = MockData.MockPersonEnumerator.GetDataTable<MockPerson>();
            Assert.AreEqual<string>(MockData.MockPersonListXml, actual.GetUnformattedXml());
        }
    }
}
